package com.you.redis.zset;

import com.you.redis.util.JedisUtils;
import redis.clients.jedis.Jedis;

/**
 * 使用jedis测试zset有序集合的数据类型
 */
public class RedisZsetDemo {

    public static void main(String[] args) throws Exception {
        Jedis jedis = JedisUtils.getInstance().getJedis();
        //存放数据 按score 进行排序
        jedis.zadd("userss", 12, "libai");
        jedis.zadd("userss", 56, "zhangsan");
        jedis.zadd("userss", 89, "wangwu");
        jedis.zadd("userss", 58, "uu");
        jedis.zadd("userss", 1, "start");
        System.out.println(jedis.zrange("userss", 0, -1));//获取加入userss中的value
        System.out.println(jedis.zrem("userss", "wangwu"));//移除
        System.out.println(jedis.zrange("userss", 0, -1));//获取加入userss中的value

        System.out.println(jedis.zrank("userss", "uu"));//元素的索引值
    }
}
